<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">编辑材料说明书的功能性</h4>
</div>
<form id="function-form" action="/xqc/products/material-supplier-ajax" method="post">
    <div class="modal-body">
        <div class="box-body">
            <h4>基本信息</h4>
            <div class="box-body table-responsive no-padding">
                <table class="table">
                    <thead>
                    <tr>
                        <th>供应商简称</th>
                        <th>供应商材料编码</th>
                        <th>材料编码</th>
                        <th>材料名称</th>
                        <th>应用大类</th>
                        <th>应用小类</th>
                        <th>材料大类</th>
                        <th>材料中类</th>
                        <th>材料小类</th>
                        <th>状态</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>{{ $psm->supplier->short_name ?? '' }}</td>
                        <td>{{ $psm->supplier_material_no }}</td>
                        <td>{{ $psm->material->material_code ?? '' }}</td>
                        <td>{{ $psm->material->title ?? '' }}</td>
                        <td>{{ $psm->material->material_application_max->title ?? '' }}</td>
                        <td>{{ $psm->material->material_application_min->title ?? '' }}</td>
                        <td>{{ $psm->material->material_classify_max->title ?? '' }}</td>
                        <td>{{ $psm->material->material_classify_mid->title ?? '' }}</td>
                        <td>{{ $psm->material->material_classify_min->title ?? '' }}</td>
                        <td>{{ \App\Models\Product\ProductSupplierM::$_auditStatus[$psm->audit_status] }}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="box-body">
            <h4>编辑</h4>
            <div class="row">
                <div class="form-group" style="padding-bottom: 30px;">
                    <label style="padding-top: 8px;text-align: right;" for="function1" class="col-sm-3 control-label">功能性</label>
                    <div class="col-sm-8">
                        <select id="function1" name="param[function][]" multiple>
                            {{ getMultipleOptions(\App\Models\Product\ProductSupplierM::$_function,!empty($psm->function) ? $psm->function : [],false) }}
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        {{ csrf_field() }}
        <input type="hidden" name="param[id]" value="{{ $id }}">
        <input type="hidden" name="action" value="doUpdateFunction">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary">提交</button>
    </div>
</form>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $("#function1").select2({"allowClear":true, "placeholder":"请选择功能性","width": '100%'});

        $("#function-form").ajaxForm(function (data) {
            if (typeof data === 'object') {
                if (data.status) {
                    $("#functionModal").modal('hide');
                    $(".modal-backdrop").remove();
                    $('body').removeClass('modal-open');
                    toastr.success('提交成功 !');
                    $.pjax.reload('#pjax-container');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        });
    });
</script>
